<template>
  <div>
    <el-form :model="form" label-width="auto" style="width: 600px" class="box1">
      <el-form-item label="标题">
        <el-input v-model="form.title" />
      </el-form-item>
      <el-form-item label="内容">
        <el-input v-model="form.content" />
      </el-form-item>
      <el-form-item label="是否发布">
        <el-switch v-model="value1" />
      </el-form-item>

      <el-button type="primary" @click="sendFn">确认</el-button>
      <el-button>取消</el-button>
    </el-form>
  </div>
</template>
<script lang="ts" setup>
import { IssueAPI } from "@/api/api";
import { ref, reactive } from "vue";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
let router = useRouter();

const value1 = ref(true);
const form = reactive({
  title: "",
  content: "",
});

const sendFn = () => {
  IssueAPI(form.title, form.content, value1.value).then((r) => {
    console.log(r.data);
    ElMessage({
      showClose: true,
      message: "发布成功",
      type: "success",
    });
    (form.title = ""), (form.title = ""), (value1.value = false);
    router.push("/article");
  });
};
</script>

<style></style>
